package seentao.stdev.mobile.study.controller;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import lombok.extern.log4j.Log4j;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import seentao.stdev.mobile.base.model.DataModel;
import seentao.stdev.mobile.base.model.Model;
import seentao.stdev.mobile.base.model.SuccessModel;
import seentao.stdev.mobile.webuser.vo.WebUser;

@Log4j
@RestController
@RequestMapping("/serv/study")
public class StudyController {
	
	@Resource
	private ServletContext servletContext;
	
	@RequestMapping("getPptPage")
	public Model getPptPage() {
		String imagePath = (String) servletContext.getAttribute("imagePath");
		
		if (imagePath == null) {
			imagePath = servletContext.getContextPath() + "/html/ppt/1.png";
			servletContext.setAttribute("imagePath", imagePath);
		}
		
		Map<String, String> data = new HashMap<>();
		data.put("imagePath", imagePath);
		return new DataModel(data);
	}
	
	@RequestMapping("setPptPage")
	public Model setPptPage(String imagePath) {
		servletContext.setAttribute("imagePath", servletContext.getContextPath() + imagePath);
		return new SuccessModel();
	}
	
}
